<?php
/**
 * 
 * @author Natanael
 * modelo de la tabla de idioma de registro de nombre
 * 
 */
class Mrnidioma extends Model{

        private $_nameTable = "RN_Idioma";
         
         public function __construct()
         {
            parent::Model();
		    $this->load->database();	  
         }
         
         public function loadIdioma($start = false, $offset = false, $sortname = false, $sortorder = false)
         {
            
              if($offset != false)
				  $this->db->limit($offset, $start);

			  if($sortname != false && $sortorder != false) 
				  $this->db->order_by($sortname, $sortorder);
				  
		      $result = $this->db->get_where($this->_nameTable);
	
			  return $this->GetArrayFromQueryResult($result);
			
         }
         
         public function LoadIdiomaById($idActividad) 
	     {
		     $qresult = $this->db->get_where($this->_nameTable, array('Id_Idioma' => $idActividad));		
		
		     if ($qresult->num_rows() == 0)
		     {
			   return false;
		     }	
           
		     return new RN_Idioma($qresult->row());
	     }
            
         public function GetArrayFromQueryResult($result) 
	     {
			  if ($result->num_rows() == 0)
				  return false;
	
			   $estatus_arr = array();
	
			  foreach ($result->result() as $record) {
				  $estatus_arr[] = new RN_Idioma($record);
			  }
	
			return $estatus_arr;
         }
         
         public function crear($data)
         {
             if ($this->db->insert($this->_nameTable,$data)) {
           	    return true;
             }
           
              return false;
        } 
        
        public function edit($data, $id)
        {
            if ($this->db->update($this->_nameTable,$data,array('Id_Idioma'=>$id))) {
           	   return true;
            }
           
             return false;
        }
        
        public function delete($id)
        {
              if ($this->db->delete($this->_nameTable,array('Id_Idioma'=>$id))) {
           	     return true;
              }
           
               return false;
        }

}

class RN_Idioma{
          
	     private $_idIdioma = 0;
	     private $_descIdioma = "";
	     private $_pIdioma = 0;
	     
	     public function __construct($ojt)
	     {
	        $this->setIdIdioma($ojt->Id_Idioma);
	        $this->setDescIdioma($ojt->Desc_Idioma);
	        $this->setPIdioma($ojt->pidioma);
	     } 
	     
	     public function getIdIdioma(){
	        return $this->_idIdioma;
	     }
	     
         public function setIdIdioma($ojt){
	        $this->_idIdioma = $ojt;
	     }
	     
	     public function getDescIdioma()
	     {
	        return $this->_descIdioma;
	     }
	     
         public function setDescIdioma($ojt)
	     {
	        $this->_descIdioma = $ojt;
	     }
	     
         public function getPIdioma()
	     {
	        return $this->_pIdioma;
	     }
	     
         public function setPIdioma($ojt)
	     {
	        $this->_pIdioma = $ojt;
	     }
}